﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using IronCow.UnitTests.Mock;

namespace IronCow.UnitTests
{
    [TestFixture]
    public class TestTimeline
    {
        [Test]
        public void TestStartTimeline()
        {
            MockRtm rtm = new MockRtm();
            rtm.AddResponse("rtm.timelines.create", new MockSuccessResponse() { new MockTimelineResponsePart(12741021) });

            Assert.IsFalse(rtm.HasTimeline);
            int timeline = rtm.StartTimeline();
            Assert.AreEqual(12741021, timeline);
            Assert.IsTrue(rtm.HasTimeline);
            Assert.AreEqual(timeline, rtm.CurrentTimeline);
        }

        [Test]
        public void TestGetOrStartTimeline()
        {
            MockRtm rtm = new MockRtm();
            rtm.AddResponse("rtm.timelines.create", new MockSuccessResponse() { new MockTimelineResponsePart(12741021) });
            rtm.AddResponse("rtm.timelines.create", new MockSuccessResponse() { new MockTimelineResponsePart(49803792) });

            Assert.IsFalse(rtm.HasTimeline);
            int timeline1 = rtm.GetOrStartTimeline();
            Assert.AreEqual(12741021, timeline1);
            Assert.IsTrue(rtm.HasTimeline);
            Assert.AreEqual(timeline1, rtm.CurrentTimeline);
            int timeline2 = rtm.GetOrStartTimeline();
            Assert.AreEqual(timeline1, timeline2);
            Assert.AreEqual(timeline1, rtm.CurrentTimeline);
        }
    }
}
